#pragma once
#include <queue>
#include <utility>
#include "general.h"
#include "card.h"

class Player {
public:
    enum class Identity:char {
        None,   //无身份
        Lord,   //主公
        Loyal,  //忠臣
        Anti,   //反贼
        Insider
    };

    explicit Player(const General& general, Hand* hand, std::list<Card*> cards = {}, Identity identity = Identity::None, bool o = false): general(general), hp(general.getHp()), hand(hand), cards(std::move(cards)), identity(identity), over(o), stageStatus(0) {}
    explicit Player(General&& general, Hand* hand, std::list<Card*>&& cards = {}, Identity identity = Identity::None, bool o = false): general(general), hp(general.getHp()), hand(hand), cards(std::move(cards)), identity(identity), over(o), stageStatus(0) {}
    [[nodiscard]] const General& getGeneral() const;
    const Player& setHp(int h);
    [[nodiscard]] int getHp() const;
    const Player& setIdentity(Identity x);
    const Player& setOver(bool o);
    [[nodiscard]] bool getOver() const;
    [[nodiscard]] Identity getIdentity() const;
    const Player& setAttack(Card* x);
    [[nodiscard]] const Card* getAttack() const;
    const Player& setArmor(Card* x);
    [[nodiscard]] const Card* getArmor() const;
    const Player& setPlusHorse(Card* x);
    [[nodiscard]] const Card* getPlusHorse() const;
    const Player& setLessHorse(Card* x);
    [[nodiscard]] const Card* getLessHorse() const;
    const Player& setStageStatus(int x);
    const Player& setStageStatus(Skill::Stage x);
    [[nodiscard]] int getStageStatus() const;
    bool isStageStatus(Skill::Stage x) const;

    //准备阶段
    const Player& ready();
    //判定阶段
    const Player& determination();
    //摸牌阶段
    const Player& draw();
    //出牌阶段
    const Player& playCord();
    //弃牌阶段
    const Player& fold();
    //结束阶段
    const Player& end();

    //摸牌
    const Player& drawCards(const std::list<Card*>& x);
    //牌列表
    [[nodiscard]] const std::list<Card*>& getCards() const;
    //其他方式获得牌
    const Player& addCard(Card* c);
    //弃牌
    const Player& delCard(const std::list<Card*>::iterator& i);
    const Player& delCard(Card* card);
    //添加延时锦囊
    const Player& pushTip(Card* c);
    const Card* popTip();
    //询问出牌
    Card* enquirePlayCard(Card::Type type);
    const Player& roundBefore(std::queue<Card*>& queue, std::queue<Card*>& heap, Player& nextPlay);
    const Player& playCards();
    const Player& roundAfter();
    bool operator == (const Player& player) const;
    bool operator != (const Player& player) const;
private:
    General general;
    //血量
    int hp;
    Identity identity;
    int stageStatus;
    bool over;
    //攻击装备
    Card* attack{};
    //防御装备
    Card* armor{};
    //马（加距离）
    Card* plusHorse{};
    //马（减距离）
    Card* lessHorse{};
    //手牌
    std::list<Card*> cards;
    //延时锦囊（其他忘记使用的乐不思蜀等）
    std::queue<Card*> tips;
    Hand* hand;
};